home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 1 / Gekikoh Dennoh Club Vol. 1 (Japan).7z / Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin / kowin / archive / apl / gv_rev11.lzh / gv_rev.c next >
Encoding:
C/C++ Source or Header  |  1995-02-16  |  4.1 KB  |  193 lines

  1. /*
  2.     Copyright 1995 Ogasawara Hiroyuki(COR.)
  3. */
  4.  
  5. #include    <corlib.h>
  6. #include    <sys_doslib.h>
  7.  
  8. #include    "Sesse.inc"
  9.  
  10. #define        PROG        "GV_Rev v1.10"
  11.  
  12. #define        GVIEWWIN    "gview.win"
  13. #define        XSIZE        80
  14. #define        YSIZE        42
  15.  
  16. int        WindowHeapSize= 1024*0;
  17.  
  18. static void
  19. WaitMark()
  20. {
  21.     MouseSetPattern( 1, &SessePattern, 7, 3 );
  22.     MS_SEL( 1 );
  23. }
  24.  
  25. static void
  26. MakeNewGWin( ng, gp )
  27. UGraphic    *ng, *gp;
  28. {
  29.     EventInfo    info;
  30.     ng->palet= gp->palet;
  31.     ng->color= gp->color;
  32.     info.option= EventUser;
  33.     info.ComBuffer= ng;
  34.     info.ComData= UserGraphic;
  35.     PidSendEvent( GVIEWWIN, &info, TRUE );
  36.     MFREE( ng->buf );
  37. }
  38.  
  39. GV_Rot( gp )
  40. UGraphic    *gp;
  41. {
  42.     UGraphic    ng;
  43.     WaitMark();
  44.     if( gp->color == WindowAttrGraphic65536 ){
  45.         unsigned short    *str= MALLOC( gp->h*gp->v*2 ),
  46.                 *ptr= gp->buf;
  47.         int    x, y;
  48.         if( (int)(ng.buf= str) < 0 )
  49.             return    FALSE;
  50.         for( y= 0 ; y< gp->h ; y++ ){
  51.             for( x= gp->v-1 ; x >= 0 ; x-- )
  52.                 *str++= ptr[x*gp->h +y];
  53.         }
  54.     }else{
  55.         unsigned char    *str= MALLOC( gp->h*gp->v ),
  56.                 *ptr= (void*)gp->buf;
  57.         int    x, y;
  58.         if( (int)(ng.buf= (void*)str) < 0 )
  59.             return    FALSE;
  60.         for( y= 0 ; y< gp->h ; y++ ){
  61.             for( x= gp->v-1 ; x >= 0 ; x-- )
  62.                 *str++= ptr[x*gp->h +y];
  63.         }
  64.     }
  65.     ng.h= gp->v;
  66.     ng.v= gp->h;
  67.     MakeNewGWin( &ng, gp );
  68.     MS_SEL( 0 );
  69.     return    TRUE;
  70. }
  71.  
  72. GV_Rev( gp, mode )
  73. UGraphic    *gp;
  74. {
  75.     EventInfo    info;
  76.     UGraphic    ng;
  77.     WaitMark();
  78.     if( gp->color == WindowAttrGraphic65536 ){
  79.         unsigned short    *str= MALLOC( gp->h*gp->v*2 ),
  80.                 *ptr= gp->buf;
  81.         int    x, y;
  82.         if( (int)(ng.buf= str) < 0 )
  83.             return    FALSE;
  84.         if( mode ){
  85.             for( y= gp->v-1 ; y>= 0 ; y-- ){
  86.                 for( x= 0 ; x < gp->h ; x++ )
  87.                     *str++= ptr[y*gp->h+ x];
  88.             }
  89.         }else{
  90.             for( y= 0 ; y < gp->v ; y++ ){
  91.                 for( x= gp->h-1 ; x>= 0 ; x-- )
  92.                     *str++= ptr[y*gp->h+ x];
  93.             }
  94.         }
  95.     }else{
  96.         unsigned char    *str= MALLOC( gp->h*gp->v ),
  97.                 *ptr= (void*)gp->buf;
  98.         int    x, y;
  99.         if( (int)(ng.buf= (void*)str) < 0 )
  100.             return    FALSE;
  101.         if( mode ){
  102.             for( y= gp->v-1 ; y>= 0 ; y-- ){
  103.                 for( x= 0 ; x < gp->h ; x++ )
  104.                     *str++= ptr[y*gp->h+ x];
  105.             }
  106.         }else{
  107.             for( y= 0 ; y < gp->v ; y++ ){
  108.                 for( x= gp->h-1 ; x>= 0 ; x-- )
  109.                     *str++= ptr[y*gp->h+ x];
  110.             }
  111.         }
  112.     }
  113.     ng.h= gp->h;
  114.     ng.v= gp->v;
  115.     MakeNewGWin( &ng, gp );
  116.     MS_SEL( 0 );
  117.     return    TRUE;
  118. }
  119.  
  120.  
  121. static int
  122. EventExec( wp, info )
  123. WindowID    wp;
  124. EventInfo    *info;
  125. {
  126.     DrawBuf    dbuf[4];
  127.     switch( info->option ){
  128.         case EventOpen:
  129.             WindowSetEventAttr( wp,  EventOpenON|EventRedrawON
  130.                 |EventCloseON|EventMouseSwitchON|EventIconifyON
  131.                 |EventUserON );
  132.             WindowRedraw( wp );
  133.             return    TRUE;
  134.         case EventIconify:
  135.             IconEnt( wp, PROG, AttrDefault, 12 );
  136.             return    TRUE;
  137.         case EventRedraw:
  138.             DrawSetClear( dbuf, ColorGray );
  139.             DrawSetSymbol( dbuf+1, 3, 1, PROG, 9|4, 12 );
  140.             DrawSetSymbol( dbuf+2, 3,14, "[回転][↑↓]", 9, 12 );
  141.             DrawSetSymbol( dbuf+3, 3,26, "------[←→]", 9, 12 );
  142.             WindowDraw( wp, dbuf, 4 );
  143.             return    TRUE;
  144.         case EventClose:
  145.             WindowClose( wp );
  146.             WindowConnectionClose();
  147.             return    TRUE;
  148.         case EventUser:
  149.             switch( info->ComData ){
  150.             case UserGraphic:
  151.                 if( info->y >= 30+14 )
  152.                     GV_Rev( info->ComBuffer, 0 );
  153.                 else if( info->x < XSIZE/2 )
  154.                     GV_Rot( info->ComBuffer );
  155.                 else
  156.                     GV_Rev( info->ComBuffer, 1 );
  157.                 return    TRUE;
  158.             case UserString:
  159.             case UserPaste:
  160.             case UserStrings:
  161.                 break;
  162.             }
  163.             return    FALSE;
  164.  
  165.         case EventMouseSwitch:
  166.             if( info->LeftON ){
  167.                 ConsoleOpen();
  168.                 ConsolePrint(
  169. "\r\n" PROG " 1995 COR.\r\n"
  170. "------------------------------------------------------------------------\r\n"
  171. "16/256/65536色画像データを上下左右反転、または 90度回転を行います。入出\r\n"
  172. "力は EventUser の UserGraphic で行います。出力に gview.win が必要です。\r\n"
  173. "------------------------------------------------------------------------\r\n"
  174.                 );
  175.                 return    TRUE;
  176.             }
  177.             return    FALSE;
  178.     }
  179.     return    FALSE;
  180. }
  181.  
  182.  
  183. void
  184. WindowMain( argc, argv )
  185. char    **argv;
  186. {
  187.     int    x= 300, y= 0;
  188.     argc= AnalyzeArgs( argc, argv, &x, &y, NULL, NULL );
  189.     WindowTitleOpen( x, y, XSIZE, YSIZE, NULL, " ",
  190.                         Close|Push|Icon, EventExec );
  191. }
  192.  
  193.